<!--
Copyright Louis Dionne 2013-2017
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
-->
<!-- boost-no-inspect -->
<!-- HTML header for doxygen 1.8.9.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<title>Boost.Hana: Metafunction</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
// Copyright Louis Dionne 2013-2017
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
MathJax.Hub.Config({
    "HTML-CSS": {
        linebreaks: {
            automatic: true,
            width: "75% container"
        }
    }
});
</script>
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<!-- Additional javascript for drawing charts. -->
<script type="text/javascript" src="highcharts.js"></script>
<script type="text/javascript" src="highcharts-data.js"></script>
<script type="text/javascript" src="highcharts-exporting.js"></script>
<script type="text/javascript" src="chart.js"></script>
<script type="text/javascript" src="hana.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="Boost.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">Boost.Hana
   &#160;<span id="projectnumber">1.7.1</span>
   </div>
   <div id="projectbrief">Your standard library for metaprogramming</div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.svg"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('group__group-_metafunction.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">Metafunction<div class="ingroups"><a class="el" href="group__group-concepts.html">Concepts</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Description</h2>
<p>A <code>Metafunction</code> is a function that takes <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code>s as inputs and returns a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code> as output. </p>
<p>A <code>Metafunction</code> is an object satisfying the <a href="http://en.cppreference.com/w/cpp/named_req/FunctionObject">FunctionObject</a> concept, but with additional requirements. First, it must be possible to apply a <code>Metafunction</code> to arguments whose tag is <code><a class="el" href="structboost_1_1hana_1_1type__tag.html" title="Tag representing hana::type.">type_tag</a></code>, and the result of such an application must be an object whose tag is also <code><a class="el" href="structboost_1_1hana_1_1type__tag.html" title="Tag representing hana::type.">type_tag</a></code>. Note that <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code> and <code><a class="el" href="structboost_1_1hana_1_1basic__type.html" title="Base class of hana::type; used for pattern-matching.">hana::basic_type</a></code> are the only such types.</p>
<p>Secondly, a <code>Metafunction</code> must provide a nested <code>::apply</code> template which allows performing the same type-level computation as is done by the call operator. In Boost.MPL parlance, a <code>Metafunction</code> <code>F</code> is hence a <a href="http://www.boost.org/doc/libs/release/libs/mpl/doc/refmanual/metafunction-class.html">MetafunctionClass</a> in addition to being a <code>FunctionObject</code>. Rigorously, the following must be satisfied by any object <code>f</code> of type <code>F</code> which is a <code>Metafunction</code>, and for arbitrary types <code>T...</code>: </p><div class="fragment"><div class="line">f(hana::type_c&lt;T&gt;...) == hana::type_c&lt;<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">F::apply</a>&lt;T...&gt;::type&gt;</div>
<div class="ttc" id="agroup__group-functional_html_ga30027c383676084be151ef3c6cf2829f"><div class="ttname"><a href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">boost::hana::apply</a></div><div class="ttdeci">constexpr auto apply</div><div class="ttdoc">Invokes a Callable with the given arguments.</div><div class="ttdef"><b>Definition:</b> apply.hpp:40</div></div>
</div><!-- fragment --><p>Thirdly, to ease the inter-operation of values and types, <code>Metafunction</code>s must also allow being called with arguments that are not <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code>s. In that case, the result is equivalent to calling the metafunction on the types of the arguments. Rigorously, this means that for arbitrary objects <code>x...</code>, </p><div class="fragment"><div class="line">f(x...) == f(hana::type_c&lt;decltype(x)&gt;...)</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md134"></a>
Minimal complete definition</h2>
<p>The <code>Metafunction</code> concept does not have a minimal complete definition in terms of tag-dispatched methods. Instead, the syntactic requirements documented above should be satisfied, and the <code>Metafunction</code> struct should be specialized explicitly in Hana's namespace.</p>
<h2><a class="anchor" id="autotoc_md135"></a>
Concrete models</h2>
<p><code><a class="el" href="group__group-_metafunction.html#gaaa4f85cb8cbce21f5c04ef40ca35cc6a" title="Lift a MPL-style metafunction to a Metafunction.">hana::metafunction</a></code>, <code><a class="el" href="group__group-_metafunction.html#gacec153d7f86aa7cf1efd813b3fd212b4" title="Lift a MPL-style metafunction class to a Metafunction.">hana::metafunction_class</a></code>, <code><a class="el" href="group__group-_metafunction.html#ga246419f6c3263b648412f346106e6543" title="Lift a template to a Metafunction.">hana::template_</a></code></p>
<h2><a class="anchor" id="autotoc_md136"></a>
Rationale: Why aren't &lt;tt&gt;Metafunction&lt;/tt&gt;s &lt;tt&gt;Comparable&lt;/tt&gt;?</h2>
<p>When seeing <code><a class="el" href="group__group-_metafunction.html#ga246419f6c3263b648412f346106e6543" title="Lift a template to a Metafunction.">hana::template_</a></code>, a question that naturally arises is whether <code>Metafunction</code>s should be made <code>Comparable</code>. Indeed, it would seem to make sense to compare two templates <code>F</code> and <code>G</code> with <code>template_&lt;F&gt; == template_&lt;G&gt;</code>. However, in the case where <code>F</code> and/or <code>G</code> are alias templates, it makes sense to talk about two types of comparisons. The first one is <em>shallow</em> comparison, and it determines that two alias templates are equal if they are the same alias template. The second one is <em>deep</em> comparison, and it determines that two template aliases are equal if they alias the same type for any template argument. For example, given <code>F</code> and <code>G</code> defined as </p><div class="fragment"><div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div>
<div class="line"><span class="keyword">using</span> F = void;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div>
<div class="line"><span class="keyword">using</span> G = void;</div>
</div><!-- fragment --><p>shallow comparison would determine that <code>F</code> and <code>G</code> are different because they are two different template aliases, while deep comparison would determine that <code>F</code> and <code>G</code> are equal because they always expand to the same type, <code>void</code>. Unfortunately, deep comparison is impossible to implement because one would have to check <code>F</code> and <code>G</code> on all possible types. On the other hand, shallow comparison is not satisfactory because <code>Metafunction</code>s are nothing but functions on <code>type</code>s, and the equality of two functions is normally defined with deep comparison. Hence, we adopt a conservative stance and avoid providing comparison for <code>Metafunction</code>s. </p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
Variables</h2></td></tr>
<tr class="memitem:ga246419f6c3263b648412f346106e6543"><td class="memTemplParams" colspan="2">template&lt;template&lt; typename ... &gt; class F&gt; </td></tr>
<tr class="memitem:ga246419f6c3263b648412f346106e6543"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__group-_metafunction.html#ga246419f6c3263b648412f346106e6543">boost::hana::template_</a></td></tr>
<tr class="memdesc:ga246419f6c3263b648412f346106e6543"><td class="mdescLeft">&#160;</td><td class="mdescRight">Lift a template to a Metafunction.  <a href="group__group-_metafunction.html#ga246419f6c3263b648412f346106e6543">More...</a><br /></td></tr>
<tr class="separator:ga246419f6c3263b648412f346106e6543"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaaa4f85cb8cbce21f5c04ef40ca35cc6a"><td class="memTemplParams" colspan="2">template&lt;template&lt; typename ... &gt; class F&gt; </td></tr>
<tr class="memitem:gaaa4f85cb8cbce21f5c04ef40ca35cc6a"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__group-_metafunction.html#gaaa4f85cb8cbce21f5c04ef40ca35cc6a">boost::hana::metafunction</a></td></tr>
<tr class="memdesc:gaaa4f85cb8cbce21f5c04ef40ca35cc6a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Lift a MPL-style metafunction to a Metafunction.  <a href="group__group-_metafunction.html#gaaa4f85cb8cbce21f5c04ef40ca35cc6a">More...</a><br /></td></tr>
<tr class="separator:gaaa4f85cb8cbce21f5c04ef40ca35cc6a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacec153d7f86aa7cf1efd813b3fd212b4"><td class="memTemplParams" colspan="2">template&lt;typename F &gt; </td></tr>
<tr class="memitem:gacec153d7f86aa7cf1efd813b3fd212b4"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__group-_metafunction.html#gacec153d7f86aa7cf1efd813b3fd212b4">boost::hana::metafunction_class</a></td></tr>
<tr class="memdesc:gacec153d7f86aa7cf1efd813b3fd212b4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Lift a MPL-style metafunction class to a Metafunction.  <a href="group__group-_metafunction.html#gacec153d7f86aa7cf1efd813b3fd212b4">More...</a><br /></td></tr>
<tr class="separator:gacec153d7f86aa7cf1efd813b3fd212b4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf7045fe6a627f88f5f646dad22d37aae"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_metafunction.html#gaf7045fe6a627f88f5f646dad22d37aae">boost::hana::integral</a></td></tr>
<tr class="memdesc:gaf7045fe6a627f88f5f646dad22d37aae"><td class="mdescLeft">&#160;</td><td class="mdescRight">Turn a <code>Metafunction</code> into a function taking <code>type</code>s and returning a default-constructed object.  <a href="group__group-_metafunction.html#gaf7045fe6a627f88f5f646dad22d37aae">More...</a><br /></td></tr>
<tr class="separator:gaf7045fe6a627f88f5f646dad22d37aae"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6d4093318f46472e62f9539a4dc998a9"><td class="memTemplParams" colspan="2">template&lt;template&lt; typename ... &gt; class F&gt; </td></tr>
<tr class="memitem:ga6d4093318f46472e62f9539a4dc998a9"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__group-_metafunction.html#ga6d4093318f46472e62f9539a4dc998a9">boost::hana::trait</a> = <a class="el" href="group__group-_metafunction.html#gaf7045fe6a627f88f5f646dad22d37aae">hana::integral</a>(<a class="el" href="group__group-_metafunction.html#gaaa4f85cb8cbce21f5c04ef40ca35cc6a">hana::metafunction</a>&lt;F&gt;)</td></tr>
<tr class="memdesc:ga6d4093318f46472e62f9539a4dc998a9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Alias to <code>integral(metafunction&lt;F&gt;)</code>, provided for convenience.  <a href="group__group-_metafunction.html#ga6d4093318f46472e62f9539a4dc998a9">More...</a><br /></td></tr>
<tr class="separator:ga6d4093318f46472e62f9539a4dc998a9"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Variable Documentation</h2>
<a id="ga246419f6c3263b648412f346106e6543"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga246419f6c3263b648412f346106e6543">&#9670;&nbsp;</a></span>template_</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;template&lt; typename ... &gt; class F&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto boost::hana::template_</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">constexpr</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.hpp</a>&gt;</code></p>
<b>Initial value:</b><div class="fragment"><div class="line">= [](basic_type&lt;T&gt;...) {</div>
<div class="line">        <span class="keywordflow">return</span> hana::type_c&lt;F&lt;T...&gt;&gt;;</div>
<div class="line">    }</div>
</div><!-- fragment -->
<p>Lift a template to a Metafunction. </p>
<p>Given a template class or template alias <code>f</code>, <code>template_&lt;f&gt;</code> is a <code>Metafunction</code> satisfying </p><div class="fragment"><div class="line">template_&lt;f&gt;(type_c&lt;x&gt;...) == type_c&lt;f&lt;x...&gt;&gt;</div>
<div class="line">decltype(template_&lt;f&gt;)::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>&lt;x...&gt;::type == f&lt;x...&gt;</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>In a SFINAE context, the expression <code>template_&lt;f&gt;(type_c&lt;x&gt;...)</code> is valid whenever the expression <code>f&lt;x...&gt;</code> is valid.</dd></dl>
<h2><a class="anchor" id="autotoc_md396"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;type_traits&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> ...&gt; <span class="keyword">struct </span>f;</div>
<div class="line"><span class="keyword">struct </span>x;</div>
<div class="line"><span class="keyword">struct </span>y;</div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::template_&lt;f&gt;() == hana::type_c&lt;f&lt;&gt;&gt;);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::template_&lt;f&gt;(hana::type_c&lt;x&gt;) == hana::type_c&lt;f&lt;x&gt;&gt;);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::template_&lt;f&gt;(hana::type_c&lt;x&gt;, hana::type_c&lt;y&gt;) == hana::type_c&lt;f&lt;x, y&gt;&gt;);</div>
<div class="line"> </div>
<div class="line">static_assert(std::is_same&lt;</div>
<div class="line">    decltype(hana::template_&lt;f&gt;)::apply&lt;x, y&gt;::type,</div>
<div class="line">    f&lt;x, y&gt;</div>
<div class="line">&gt;::<a class="code" href="group__group-_constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
<div class="ttc" id="aassert_8hpp_html"><div class="ttname"><a href="assert_8hpp.html">assert.hpp</a></div><div class="ttdoc">Defines macros to perform different kinds of assertions.</div></div>
<div class="ttc" id="aequal_8hpp_html"><div class="ttname"><a href="equal_8hpp.html">equal.hpp</a></div><div class="ttdoc">Defines boost::hana::equal.</div></div>
<div class="ttc" id="agroup__group-_constant_html_ga1687520692a6b0c49e3a69de2980f388"><div class="ttname"><a href="group__group-_constant.html#ga1687520692a6b0c49e3a69de2980f388">boost::hana::value</a></div><div class="ttdeci">constexpr auto value</div><div class="ttdoc">Return the compile-time value associated to a constant.</div><div class="ttdef"><b>Definition:</b> value.hpp:54</div></div>
<div class="ttc" id="agroup__group-assertions_html_ga2c5006540936d9f8880e3a39f4fcc035"><div class="ttname"><a href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a></div><div class="ttdeci">#define BOOST_HANA_CONSTANT_CHECK(...)</div><div class="ttdoc">Equivalent to BOOST_HANA_CONSTANT_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERTI...</div><div class="ttdef"><b>Definition:</b> assert.hpp:239</div></div>
<div class="ttc" id="anamespaceboost_1_1hana_html"><div class="ttname"><a href="namespaceboost_1_1hana.html">boost::hana</a></div><div class="ttdoc">Namespace containing everything in the library.</div><div class="ttdef"><b>Definition:</b> accessors.hpp:20</div></div>
<div class="ttc" id="atype_8hpp_html"><div class="ttname"><a href="type_8hpp.html">type.hpp</a></div><div class="ttdoc">Defines boost::hana::type and related utilities.</div></div>
</div><!-- fragment --> 
</div>
</div>
<a id="gaaa4f85cb8cbce21f5c04ef40ca35cc6a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaaa4f85cb8cbce21f5c04ef40ca35cc6a">&#9670;&nbsp;</a></span>metafunction</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;template&lt; typename ... &gt; class F&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto boost::hana::metafunction</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">constexpr</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.hpp</a>&gt;</code></p>
<b>Initial value:</b><div class="fragment"><div class="line">= [](basic_type&lt;T&gt;...) {</div>
<div class="line">        <span class="keywordflow">return</span> hana::type_c&lt;<span class="keyword">typename</span> F&lt;T...&gt;::type&gt;;</div>
<div class="line">    }</div>
</div><!-- fragment -->
<p>Lift a MPL-style metafunction to a Metafunction. </p>
<p>Given a MPL-style metafunction, <code>metafunction&lt;f&gt;</code> is a <code>Metafunction</code> satisfying </p><div class="fragment"><div class="line">metafunction&lt;f&gt;(type_c&lt;x&gt;...) == type_c&lt;f&lt;x...&gt;::type&gt;</div>
<div class="line">decltype(metafunction&lt;f&gt;)::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>&lt;x...&gt;::type == f&lt;x...&gt;::type</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>In a SFINAE context, the expression <code>metafunction&lt;f&gt;(type_c&lt;x&gt;...)</code> is valid whenever the expression <code>f&lt;x...&gt;::type</code> is valid.</dd></dl>
<h2><a class="anchor" id="autotoc_md397"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;type_traits&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> ...&gt; <span class="keyword">struct </span>f { <span class="keyword">struct </span>type; };</div>
<div class="line"><span class="keyword">struct </span>x;</div>
<div class="line"><span class="keyword">struct </span>y;</div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction&lt;f&gt;() == hana::type_c&lt;f&lt;&gt;::type&gt;);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction&lt;f&gt;(hana::type_c&lt;x&gt;) == hana::type_c&lt;f&lt;x&gt;::type&gt;);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction&lt;f&gt;(hana::type_c&lt;x&gt;, hana::type_c&lt;y&gt;) == hana::type_c&lt;f&lt;x, y&gt;::type&gt;);</div>
<div class="line"> </div>
<div class="line">static_assert(std::is_same&lt;</div>
<div class="line">    decltype(hana::metafunction&lt;f&gt;)::apply&lt;x, y&gt;::type,</div>
<div class="line">    f&lt;x, y&gt;::type</div>
<div class="line">&gt;::<a class="code" href="group__group-_constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
</div><!-- fragment --> 
</div>
</div>
<a id="gacec153d7f86aa7cf1efd813b3fd212b4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacec153d7f86aa7cf1efd813b3fd212b4">&#9670;&nbsp;</a></span>metafunction_class</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename F &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto boost::hana::metafunction_class</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">constexpr</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.hpp</a>&gt;</code></p>
<b>Initial value:</b><div class="fragment"><div class="line">= [](basic_type&lt;T&gt;...) {</div>
<div class="line">        <span class="keywordflow">return</span> hana::type_c&lt;<span class="keyword">typename</span> F::template <a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>&lt;T...&gt;::type&gt;;</div>
<div class="line">    }</div>
</div><!-- fragment -->
<p>Lift a MPL-style metafunction class to a Metafunction. </p>
<p>Given a MPL-style metafunction class, <code>metafunction_class&lt;f&gt;</code> is a <code>Metafunction</code> satisfying </p><div class="fragment"><div class="line">metafunction_class&lt;f&gt;(type_c&lt;x&gt;...) == type_c&lt;<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">f::apply</a>&lt;x...&gt;::type&gt;</div>
<div class="line">decltype(metafunction_class&lt;f&gt;)::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>&lt;x...&gt;::type == f::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>&lt;x...&gt;::type</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>In a SFINAE context, the expression <code>metafunction_class&lt;f&gt;(type_c&lt;x&gt;...)</code> is valid whenever the expression <code>f::apply&lt;x...&gt;::type</code> is valid.</dd></dl>
<h2><a class="anchor" id="autotoc_md398"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;type_traits&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">struct </span>f { <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ...&gt; <span class="keyword">struct </span><a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a> { <span class="keyword">struct </span>type; }; };</div>
<div class="line"><span class="keyword">struct </span>x;</div>
<div class="line"><span class="keyword">struct </span>y;</div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction_class&lt;f&gt;() == hana::type_c&lt;f::apply&lt;&gt;::type&gt;);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction_class&lt;f&gt;(hana::type_c&lt;x&gt;) == hana::type_c&lt;f::apply&lt;x&gt;::type&gt;);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::metafunction_class&lt;f&gt;(hana::type_c&lt;x&gt;, hana::type_c&lt;y&gt;) == hana::type_c&lt;f::apply&lt;x, y&gt;::type&gt;);</div>
<div class="line"> </div>
<div class="line">static_assert(std::is_same&lt;</div>
<div class="line">    decltype(hana::metafunction_class&lt;f&gt;)::apply&lt;x, y&gt;::type,</div>
<div class="line">    f::apply&lt;x, y&gt;::type</div>
<div class="line">&gt;::<a class="code" href="group__group-_constant.html#ga1687520692a6b0c49e3a69de2980f388">value</a>, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
</div><!-- fragment --> 
</div>
</div>
<a id="gaf7045fe6a627f88f5f646dad22d37aae"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf7045fe6a627f88f5f646dad22d37aae">&#9670;&nbsp;</a></span>integral</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto boost::hana::integral</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">constexpr</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.hpp</a>&gt;</code></p>
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span> f) {</div>
<div class="line">        <span class="keywordflow">return</span> [](basic_type&lt;T&gt;...) {</div>
<div class="line">            <span class="keywordflow">return</span> decltype(f)::<a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>&lt;T...&gt;::type{};</div>
<div class="line">        };</div>
<div class="line">    }</div>
</div><!-- fragment -->
<p>Turn a <code>Metafunction</code> into a function taking <code>type</code>s and returning a default-constructed object. </p>
<p>Given a <code>Metafunction</code> <code>f</code>, <code>integral</code> returns a new <code>Metafunction</code> that default-constructs an object of the type returned by <code>f</code>. More specifically, the following holds: </p><div class="fragment"><div class="line"><a class="code" href="group__group-_metafunction.html#gaf7045fe6a627f88f5f646dad22d37aae">integral</a>(f)(t...) == decltype(f(t...))::type{}</div>
<div class="ttc" id="agroup__group-_metafunction_html_gaf7045fe6a627f88f5f646dad22d37aae"><div class="ttname"><a href="group__group-_metafunction.html#gaf7045fe6a627f88f5f646dad22d37aae">boost::hana::integral</a></div><div class="ttdeci">constexpr auto integral</div><div class="ttdoc">Turn a Metafunction into a function taking types and returning a default-constructed object.</div><div class="ttdef"><b>Definition:</b> type.hpp:513</div></div>
</div><!-- fragment --><p>The principal use case for <code>integral</code> is to transform <code>Metafunction</code>s returning a type that inherits from a meaningful base like <code><a class="el" href="structstd_1_1integral__constant.html" title="Adapter for std::integral_constants.">std::integral_constant</a></code> into functions returning e.g. a <code><a class="el" href="structboost_1_1hana_1_1integral__constant.html" title="Compile-time value of an integral type.">hana::integral_constant</a></code>.</p>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>This is not a <code>Metafunction</code> because it does not return a <code>type</code>. As such, it would not make sense to make <code>decltype(integral(f))</code> a MPL metafunction class like the usual <code>Metafunction</code>s are.</li>
<li>When using <code>integral</code> with metafunctions returning <code><a class="el" href="structstd_1_1integral__constant.html" title="Adapter for std::integral_constants.">std::integral_constant</a></code>s, don't forget to include the <a class="el" href="ext_2std_2integral__constant_8hpp.html" title="Adapts std::integral_constant for use with Hana.">boost/hana/ext/std/integral_constant.hpp</a> header to ensure Hana can interoperate with the result.</li>
<li>In a SFINAE context, the expression <code>integral(f)(t...)</code> is valid whenever the expression <code>decltype(f(t...))::type</code> is valid.</li>
</ul>
</dd></dl>
<h2><a class="anchor" id="autotoc_md399"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="ext_2std_2integral__constant_8hpp.html">boost/hana/ext/std/integral_constant.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not_8hpp.html">boost/hana/not.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;type_traits&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">constexpr <span class="keyword">auto</span> is_void = <a class="code" href="group__group-_metafunction.html#gaf7045fe6a627f88f5f646dad22d37aae">hana::integral</a>(hana::metafunction&lt;std::is_void&gt;);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(is_void(hana::type_c&lt;void&gt;));</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-_logical.html#ga4a7c9d7037601d5e553fd20777958980">hana::not_</a>(is_void(hana::type_c&lt;int&gt;)));</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
<div class="ttc" id="aext_2std_2integral__constant_8hpp_html"><div class="ttname"><a href="ext_2std_2integral__constant_8hpp.html">integral_constant.hpp</a></div><div class="ttdoc">Adapts std::integral_constant for use with Hana.</div></div>
<div class="ttc" id="agroup__group-_logical_html_ga4a7c9d7037601d5e553fd20777958980"><div class="ttname"><a href="group__group-_logical.html#ga4a7c9d7037601d5e553fd20777958980">boost::hana::not_</a></div><div class="ttdeci">constexpr auto not_</div><div class="ttdoc">Negates a Logical.</div><div class="ttdef"><b>Definition:</b> not.hpp:31</div></div>
<div class="ttc" id="anot_8hpp_html"><div class="ttname"><a href="not_8hpp.html">not.hpp</a></div><div class="ttdoc">Defines boost::hana::not_.</div></div>
</div><!-- fragment --> 
</div>
</div>
<a id="ga6d4093318f46472e62f9539a4dc998a9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga6d4093318f46472e62f9539a4dc998a9">&#9670;&nbsp;</a></span>trait</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;template&lt; typename ... &gt; class F&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto boost::hana::trait = <a class="el" href="group__group-_metafunction.html#gaf7045fe6a627f88f5f646dad22d37aae">hana::integral</a>(<a class="el" href="group__group-_metafunction.html#gaaa4f85cb8cbce21f5c04ef40ca35cc6a">hana::metafunction</a>&lt;F&gt;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">constexpr</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="fwd_2type_8hpp.html">boost/hana/fwd/type.hpp</a>&gt;</code></p>

<p>Alias to <code>integral(metafunction&lt;F&gt;)</code>, provided for convenience. </p>
<h2><a class="anchor" id="autotoc_md400"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="ext_2std_2integral__constant_8hpp.html">boost/hana/ext/std/integral_constant.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not_8hpp.html">boost/hana/not.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;type_traits&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::trait&lt;std::is_integral&gt;(hana::type_c&lt;int&gt;));</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-_logical.html#ga4a7c9d7037601d5e553fd20777958980">hana::not_</a>(hana::trait&lt;std::is_integral&gt;(hana::type_c&lt;float&gt;)));</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
</div><!-- fragment --> 
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!--
Copyright Louis Dionne 2013-2017
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
-->
<!-- boost-no-inspect -->
<!-- HTML footer for doxygen 1.8.9.1-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
  </ul>
</div>
</body>
</html>
